package net.zigin.nhi.could.waste.model;

import java.util.Date;

import lombok.Data;
import net.zigin.commons.util.StringUtil;
import net.zigin.nhi.could.waste.aop.LoginAspect;
import net.zigin.nhi.could.waste.vo.TokenInfoBo;

/*#################################################################*
# 说明:以下代码通过哲勤代码生成工具自动生成    
# 工具:GeneratorCode
# 作者:mgw1986                                                  
# 生成时间:2021-9-12 21:08:06                                               
##################################################################*/

/**
 * 
 *  MaterialRecord实体类
 * @ClassName: MaterialRecord
 * @author mgw1986
 * @date 2021-9-12 21:08:06
 * @version V1.0
 */
@Data
public class MaterialRecord {
     //耗材记录ID--->列名: id 
	private String id;
     //耗材基础ID--->列名: material_base_id 
	private String materialBaseId;
     //员工用户ID--->列名: user_staff_id 
	private String userStaffId;
     //医院科室ID--->列名: hospital_depart_id 
	private String hospitalDepartId;
     //医院基础ID--->列名: hospital_base_id 
	private String hospitalBaseId;
     //记录类型（in：入库，out：出库）--->列名: type 
	private String type;
     //变化数量--->列名: change_num 
	private int changeNum;
     //变化前数量--->列名: before_num 
	private int beforeNum;
     //变化后数量--->列名: after_num 
	private int afterNum;
     //创建人--->列名: create_user 
	private String createUser;
     //创建时间--->列名: create_time 
	private Date createTime;
     //修改人--->列名: modify_user 
	private String modifyUser;
     //修改时间--->列名: modify_time 
	private Date modifyTime;

    public MaterialRecord() {
    }

    public MaterialRecord(MaterialBase materialBase) {
        TokenInfoBo tokenInfo = LoginAspect.getTokenInfo();
        this.id = StringUtil.get32UUID();
        this.type = "in";
        this.materialBaseId = materialBase.getId();
        this.hospitalBaseId= materialBase.getHospitalBaseId();
        this.createUser = tokenInfo == null ? null : tokenInfo.getLoginName();
        this.createTime = new Date();
        this.modifyTime = new Date();
    }

    public MaterialRecord(MaterialApply materialApply){
        TokenInfoBo tokenInfo = LoginAspect.getTokenInfo();
        this.id = StringUtil.get32UUID();
        this.type = "out";
        this.userStaffId = materialApply.getUserStaffId();
        this.materialBaseId = materialApply.getMaterialBaseId();
        this.hospitalBaseId= materialApply.getHospitalBaseId();
        this.hospitalDepartId= materialApply.getHospitalDepartId();
        this.createUser = tokenInfo == null ? null : tokenInfo.getLoginName();
        this.createTime = new Date();
        this.modifyTime = new Date();
    }
}
